package com.xhwy.controller;

import com.xhwy.entity.ProductType;
import com.xhwy.service.ProductTypeService;
import com.xhwy.util.PageUtil;
import com.xhwy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/productType")
public class ProductTypeController {
    @Autowired
    private ProductTypeService productTypeService;

    //分页查询商品类型
    @GetMapping
    public PageUtil<ProductType> queryAllByLimit(ProductType productType, PageUtil<ProductType> pageUtil) {
        return productTypeService.queryAllByLimit(productType, pageUtil);
    }

    @PostMapping
    public R addProductType(@RequestBody ProductType productType){
        return productTypeService.addProductType(productType);
    }

    @PutMapping
    public R updateProductType(@RequestBody ProductType productType){
        return productTypeService.updateProductType(productType);
    }
    @DeleteMapping("/{productTypeId}")
    public R deleteProductTypeByProductTypeId(@PathVariable Integer productTypeId){
        return productTypeService.deleteProductTypeByProductTypeId(productTypeId);
    }

    @GetMapping("list")
    public R list(){
        return productTypeService.list();
    }
}
